MsgBox "Must specify a Key", vbInformation, "No Key"
Exit Sub
End If
'
'When you use the SetEntry method without
'specifying a KeyItemName, an empty key is created
'in the registry
RegiCon1.RootKey = cboRoot.ListIndex
RegiCon1.Key = txtKey.Text
RegiCon1.KeyItemName = ""
RegiCon1.SetEntry
'
'the SubKeyNames() array and ItemNames() array
'are only valid after an EnumerateEntry method
'so we clear the list to prevent any confusion
List1.Clear
List2.Clear
End Sub
Private Sub cmdDeleteKey_Click()
If Trim$(txtKey.Text) = "" Then
MsgBox "Must specify a Key", vbInformation, "No Key"
Exit Sub
End If
If txtSubKey.Text = "" Then
MsgBox "You have chosen to delete a key directly off of a RootKey!" & vbCr & vbCrLf _
& "Although you can create keys directly off of HKEY_CLASSES_ROOT or HKEY_CURRENT_USER," & vbCrLf _
& "deleting a key from a root key is NOT normal and this sample will NOT delete this key!" & vbCr & vbCrLf _
& "Normally you should use the SubKey property to specify which portion of the multikey to delete (see the Help File)." & vbCr & vbCrLf _
, vbExclamation, "Delete Prevented By Sample!"
Exit Sub
Else
If MsgBox("Are you sure you want to delete the subkey '" & txtSubKey.Text & "' from the key '" & txtKey.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Key") = vbNo Then
Exit Sub
End If
End If
'
'To delete a Key and any of its subkeys and items,
'set Key to the parent key of the subkey to delete;
'set the SubKey to the key that you want to delete;
'
'To delete an entire key, do NOT specify a KeyItemName, otherwise
'the control will only delete the item
RegiCon1.RootKey = cboRoot.ListIndex
RegiCon1.Key = txtKey.Text
RegiCon1.SubKey = txtSubKey.Text
RegiCon1.KeyItemName = ""
RegiCon1.DeleteEntry
txtSubKey.Text = ""
txtItemValue.Text = ""
'
'the SubKeyNames() array and ItemNames() array
'are only valid after an EnumerateEntry method
'so we clear the list to prevent any confusion
List1.Clear
List2.Clear
End Sub
Private Sub cmdDeleteKeyItem_Click()
If Trim$(txtKey.Text) = "" Then
MsgBox "Must specify a Key", vbInformation, "No Key"
Exit Sub
ElseIf Trim$(txtItemName) = "" Then
MsgBox "Must specify an Item", vbInformation, "No Item"
Exit Sub
End If
If MsgBox("Are you sure you want to delete the item '" & txtItemName.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Item") = vbNo Then
Exit Sub
End If
'to delete an item from a key, specify
'the key and set the KeyItemName to the item
'that you want to delete
RegiCon1.RootKey = cboRoot.ListIndex
RegiCon1.Key = txtKey.Text
RegiCon1.KeyItemName = txtItemName.Text
RegiCon1.DeleteEntry
txtItemName.Text = ""
txtItemValue.Text = ""
'
'the SubKeyNames() array and ItemNames() array
'are only valid after an EnumerateEntry method
'so we clear the list to prevent any confusion
List1.Clear
List2.Clear
End Sub
Private Sub cmdEnumEntry_Click()
'
'clear any previous results
List1.Clear
List2.Clear
RegiCon1.RootKey = cboRoot.ListIndex
RegiCon1.Key = txtKey.Text
RegiCon1.KeyItemName = ""
RegiCon1.EnumerateEntry
'
'loop through both arrays, displaying
'the results
Dim l As Long
For l = 0 To RegiCon1.SubKeysCount - 1
List1.AddItem RegiCon1.SubKeyNames(l)
Next l
l = 0
For l = 0 To RegiCon1.ItemsCount - 1
List2.AddItem RegiCon1.ItemNames(l)
Next l
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdGetKeyItem_Click()
Dim str As String
Dim i As Integer
txtItemValue.Text = ""
If Trim$(txtKey.Text) = "" Then
MsgBox "Must specify a Key", vbInformation, "No Key"
Exit Sub
'allow getting the default key
'ElseIf Trim$(txtItemName) = "" Then
' MsgBox "Must specify an Item", vbInformation, "No Item"